package com.fc.redap.controller.api;

import com.alibaba.fastjson.JSONObject;
import com.fc.redap.controller.BaseController;
import com.fc.redap.dtos.ResponseJson;
import com.fc.redap.entity.ProjectEntity;
import com.fc.redap.entity.ScenicZoneEntity;
import com.fc.redap.service.IProjectService;
import com.fc.redap.service.IScenicZoneService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/scenic")
@Api(value="旅游景区地点相关的API", tags={"旅游景区地点"})
public class ScenicZoneController extends BaseController {

    @Autowired
    private IScenicZoneService scenicZoneService;

    @ApiOperation(value = "POST -- 获取默认景区地点列表",
            notes = " REST 方式请求。"+
                    "Request Parameter: <ul>" +
                    "<li><i>可选参数: scenicZoneName: 项目名称 模糊查询</i></li>" +
                    "<li><i>可选参数: type: 项目类型</i></li>" +
                    "<li><i>可选参数: count: 每页记录数</i></li>" +
                    "<li><i>可选参数: page: 第几页</i></li>" +
                    "</ul>",
            response = ResponseJson.class,
            httpMethod = "POST",
            consumes = "application/json",
            produces = "application/json",
            code = 200
    )
    @PostMapping("/list")
    public ResponseJson doQueryList(@RequestBody JSONObject params) {

        params.put("limit",params.get("count"));
        params.put("offset",params.get("page"));
        //校对并赋值 offset和limit
        calculatePagination(params);

        List<ScenicZoneEntity> projectList = scenicZoneService.queryList(params);
        return ResponseJson.success(projectList);
    }

}
